package com.thinkit.bigdata.core.util;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by joqk12345 on 9/23/16.
 * www.github.com/joqk12345
 */
public class DateConverter implements Converter<String,Date> {




    @Autowired
    private MessageSource messageSource;


    public Date convert(String soucre) {

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dateFormat.setLenient(false);
        System.out.println("begin to convert "+soucre);
        try {
            return dateFormat.parse(soucre);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
